import { RouteRecordRaw } from 'vue-router'

const routes:RouteRecordRaw[] = [
    {
        path:'/home',
        component:()=>import('@/views/Home/index.vue'),
        children: [
            {
                path: 'message',
                component:()=>import('@/views/Message/index.vue'),
                children: [
                    {
                        path: 'messagedetail/:id?',
                        name:'messagedetail',
                        component: () => import('@/views/MessageDetail/index.vue'),
                        // props配置写法  1,只能params传参使用
                        // props: true
                        // 2,只能传递额外数据
                        // props:{
                        //     id:1,
                        //     content:2
                        // }
                        // 3,可以传params参数 也可以传query参数 也可以传额外数据
                        props(route){
                            return{
                            id: route.params.id,
                            content: route.query.content,
                            c: '测试数据'
                            }
                        }
                    }
                ]
            },
            {
                path:'/home/news',
                component:()=>import('@/views/News/index.vue'),
                children:[
                    {
                        path:'newsdetail/:id?',
                        name:'newsdetail',
                        component:()=>import('@/views/NewsDetail/index.vue')
                    }
                ]
            },
            {
                path: '/home',
                redirect: '/home/message',
            }
        ]
    },
    {
        path:'/about',
        component:()=>import('@/views/About/index.vue')
    },
    {
        path:'/',
        redirect:'/home'
    }
]
export default routes